$("document").ready(function(){

	scrollDo();
	$("ul#menu li").click(function(){
		$("ul#menu li").removeClass("active");
		$(this).addClass("active");
	});
	$("#sponsorTabInner").click(function(){	
		$("ul#menu li").removeClass("active");
		$("li.lisix").addClass("active");
	});
	$("#frm").validate();
	$("#diamond").click(function(){
		
		$(".rspon_dia").prop('checked', true);	
	});
	$("#platinum").click(function(){
		$(".rspon_plati").prop('checked', true);	
	});
	$("#gold").click(function(){
		$(".rspon_gold").prop('checked', true);	
	});
	$("#l_diamond").click(function(){
		
		$(".rspon_dia").prop('checked', true);	
	});
	$("#l_platinum").click(function(){
		$(".rspon_plati").prop('checked', true);	
	});
	$("#l_gold").click(function(){
		$(".rspon_gold").prop('checked', true);	
	});
	$("#diamon").click(function(){
		if ($("div.content_diamon").is(":hidden")) {
			$(this).css({'background-image':'url("./images/bg_h1_page5_ex.png")'});
		}
		else {
			$(this).css({'background-image':'url("./images/bg_h1_page5.png")'});
		}
		$("div.content_diamon").toggle();
	});
	
	$("#media").click(function(){
		if ($("div.content_media").is(":hidden")) {
			$(this).css({'background-image':'url("./images/bg_h1_page5_ex.png")'});
		}
		else {
			$(this).css({'background-image':'url("./images/bg_h1_page5.png")'});
		}
		$("div.content_media").toggle();
	});
	
	//check with for device	
	var  w = $(window).width();	
	var  h = $(window).height();
	
	if(parseInt(w) == 533) {
		$("#innerctd").css("width","100%");
	}
	//if(parseInt(h) == 450){$("div.home div.page5").addClass("mh450");} else {$("div.home div.page5").removeClass("mh450");}
		
		if(parseInt(w) <= 600){
			$("div#sponsorTab").removeClass("sponsorTab").addClass("sponsorTabMobile");
			$("div#sponsorTabInner").removeClass("sponsorTabInner").addClass("sponsorTabInnerMobile");
			$("a#btt").remove();
			$("#cm_page2").remove();
			$("#beer").remove();
			$(".txt_page3").css("padding-left","10%");
			$(".page7 .row").css("background-position","-88px -32px");
			$(".floor_plan").html('<a href="./images/hinh.jpg" target="_blank"><img style="z-index: 1;margin-top: 5px;width: 90%;" src="./images/hinh.jpg" /></a>');
			$("#f_cogai").css("margin-left","0");
			$("div.lt").css({"background":"none","min-height":"0"});
		}else {
			$("div#sponsorTab").removeClass("sponsorTabMobile").addClass("sponsorTab");
			$("div#sponsorTabInner").removeClass("sponsorTabInnerMobile").addClass("sponsorTabInner");
			$("div.ui-loader").remove();
		};
	   if(parseInt(w) <= 600){
			//$("ul#menu").html('<li><a href="#page2">ABOUT | </a></li><li><a href="#page4">EVENT INFORMATION | </a></li><li><a href="#page5">SPONSORS | </a></li><li><a href="#page6">BECOME A SPONSORS | </a></li><li><a href="#page7">GALLERY | </a></li><li><a href="#page8">CONTACT | </a></li><li><a href="#VN">VN</a> | <a href="#en">EN</a></li>');
			$("div.menu ul li").addClass("mrli");
	   }
	   else {
			
			$("div.menu ul li").removeClass("mrli");
	   }
	   
	/* Xu Ly khi click Link menu */	   
	/* ########################################################################################## */

	$('a.link').bind('click',function(event){

		if ($("div.logo-container").is(":hidden")) {
			$("div.logo-container").show("blind" );
		}

		var $anchor = $(this);
		$('html, body').stop().animate({
			scrollTop: ($($anchor.attr('href')).offset().top - 120)
		}, 1500,'easeInOutExpo');
	
		event.preventDefault();
		
	});
	

	$('a.linkAbout').bind('click',function(event){
		var $anchor = $(this);
		$('html, body').stop().animate({
			scrollTop: $($anchor.attr('href')).offset().top - 65
		}, 1500,'easeInOutExpo');
		event.preventDefault();
	})
	
	
	$(window).bind('mousewheel',function(event, delta, deltaX, deltaY){
		var h =  $(window).scrollTop();
		
		if (parseInt(h) > 1464){
			if (delta > 0)
				$("div.logo-container").show("blind", function() {});
			else
				$("div.logo-container").hide("blind", function() {});
		}
		else
			$("div.logo-container").hide("blind", function() {});
	})  
	
	
	self.setInterval(function(){ var h =  $(window).scrollTop();if (parseInt(h) < 800 && parseInt(h) > 100)$("div.logo-container").hide("blind")},2000);
	/* ########################################################################################## */	   
	/* When user resize again browser 
	 * @Start----------------------------	
	*/
		$(window).on("resize", function(event){
		  //console.log( $(this).width() );
		  var  w = $(window).width();	
			//alert(w);
			 if(parseInt(w) <= 600){
				//$("ul#menu").html('<li><a href="#page2">ABOUT | </a></li><li><a href="#page4">EVENT INFORMATION | </a></li><li><a href="#page5">SPONSORSHIP | </a></li><li><a href="#page7">GALLERY | </a></li><li><a href="#page8">CONTACT | </a></li><li><a href="#page6">BECOME A SPONSOR | </a></li><li><a href="#VN">VN</a> | <a href="#en">EN</a></li>');
				$("div.menu ul li").addClass("mrli");
				
				$("a#btt").remove();
				$("#cm_page2").remove();
				$("#beer").remove();
				$(".txt_page3").css("padding-left","10%");
				$(".page7 .row").css("background-position","-88px -32px");
				$(".floor_plan").html('<a href="./images/hinh.jpg" target="_blank"><img style="z-index: 1;margin-top: 5px;" src="./images/hinh.jpg" /></a>');
				$("div.lt").css({"background":"none","min-height":"0"});
			 }
			 else {
				$("div.menu ul li").removeClass("mrli");
			 }
			   
			if(parseInt(w) <= 600){
				$("div#sponsorTab").removeClass("sponsorTab").addClass("sponsorTabMobile");
				$("div#sponsorTabInner").removeClass("sponsorTabInner").addClass("sponsorTabInnerMobile");
				$("div.menu ul li").css({"margin-left":"2px","margin-right":"2px"});
				
			}else {
				
				$("div#sponsorTab").removeClass("sponsorTabMobile").addClass("sponsorTab");
				$("div#sponsorTabInner").removeClass("sponsorTabInnerMobile").addClass("sponsorTabInner");
				$("div.ui-loader").remove();
			}
			if(parseInt(w) <= 600){
				$("div.menu ul li").addClass("mrli");
		   }
		   else {
				$("div.menu ul li").removeClass("mrli");
		   }
		  
		   
		});
		
	/*End browser */

	$(window).scroll(function(){
		scrollDo();
	}); 

	function scrollDo(){
		var h =  $(window).scrollTop();
		console.log(h);
		/* Add classs active cho menu khi scroll */
		var hwin = $(window).height();
		if(parseInt(h)<824){
				$("ul#menu li").removeClass("active");
		}
		if(hwin == 604){
			/*
			if(parseInt(h)>=824 && parseInt(h)<1637)
			{
				$("ul#menu li").removeClass("active");
				$("li.lione").addClass("active");
			}
			if(parseInt(h)>=1637 && parseInt(h)<3037)
			{
				$("ul#menu li").removeClass("active");
				$("li.litwo").addClass("active");
			}
			if(parseInt(h)>=3037 && parseInt(h)<4534)
			{
				$("ul#menu li").removeClass("active");
				$("li.lithree").addClass("active");
			}
			if(parseInt(h)>=3037 && parseInt(h)<4534)
			{
				$("ul#menu li").removeClass("active");
				$("li.lisix").addClass("active");
			}
			if(parseInt(h)>=4534 && parseInt(h)<5234)
			{
				$("ul#menu li").removeClass("active");
				$("li.lifour").addClass("active");
			}
			if(parseInt(h)>=6609)
			{
				$("ul#menu li").removeClass("active");
				$("li.lifive").addClass("active");
			}
			*/
		 }	
		/* End addClass active cho menu khi scroll */
		if(parseInt(h) >= 342){
			$("a#btt").show("slow").css("display","block");
		}
		else {
			$("a#btt").hide("slow").css("display","none");
		}
		 if(parseInt(h)<1637){
			$("#beer").css({"background-position":"-48px 0"});
		 }
		 else if(parseInt(h)>=1637 && parseInt(h) < 1751){
			$("#beer").css({"background-position":"-439px 0"});
		 }
		 else if(parseInt(h)>=1751 && parseInt(h) < 1865){
			$("#beer").css({"background-position":"-855px 0"});
		 }
		 else if(parseInt(h)>=1865 && parseInt(h) < 1979){
			$("#beer").css({"background-position":"-1656px 0"});
		 }
		 else if(parseInt(h)>=1979){
			$("#beer").css({"background-position":"-2428px 0"});
		 }
		 if(h<228){
			$("#lg_banner").addClass("tada");
		 }
		 else {
			$("#lg_banner").removeClass("tada");
		 }
		 
		 if(h >= 798){
			$("div.menu").addClass("sticky");
		 }
		 else {
			$("div.menu").removeClass("sticky");
		}
			
		//var bHeight = $(window).height();
		//$("div.logo-container").removeClass('block');
	}
	
	$('.flexslider').flexslider({
		animation: "slide",
		direction: "horizontal",
		easing: "easeInOutCirc",
		reverse:"false",
		touch: true
		
	});

/* #################################################*/	


var intID;
intID = setInterval ( RepeatCall, 700 );

function RepeatCall() {
		
	$("#cm_page2").toggleClass('down');
}

});//End $(document).ready(function(){});


function writeObject(){		
	var zoomDataObject = $('#yourImageID').z('getZoomData');		
	$('#code').html(		
		"Normal X: <span style='color:#000000'>"+parseInt(zoomDataObject.normX) +"</span>"
		+"<br />Normal Y: <span style='color:#000000'>"+parseInt(zoomDataObject.normY) +"</span>"
		+"<br />Normal Width: <span style='color:#000000'>"+parseInt(zoomDataObject.normWidth) +"</span>"
		+"<br />Normal Height: <span style='color:#000000'>"+parseInt(zoomDataObject.normHeight) +"</span>"
		
		+"<br /><br />Scaled X: <span style='color:#000000'>"+parseInt(zoomDataObject.scaledX)  +"</span>"
		+"<br />Scaled Y: <span style='color:#000000'>"+parseInt(zoomDataObject.scaledY) +"</span>"
		+"<br />Scaled Width: <span style='color:#000000'>"+parseInt(zoomDataObject.scaledWidth) +"</span>"
		+"<br />Scaled Height: <span style='color:#000000'>"+parseInt(zoomDataObject.scaledHeight) +"</span>"

		+"<br /><br />Center X: <span style='color:#000000'>"+parseInt(zoomDataObject.centerX) +"</span>"
		+"<br />Center Y: <span style='color:#000000'>"+parseInt(zoomDataObject.centerY) +"</span>"	
		
		+"<br /><br />Scale Ratio:<br /> <span style='color:#000000'>"+zoomDataObject.ratio +"</span>"	
	);	
}

var sample=4;
var smPos=153;
var spPos=153;
var sW;
var sH;
jQuery(function($)
{
	var w = 600,
	h=485;
	$('#yourImageID').smoothZoom({
		width:w,
		height:h,
		zoom_MAX:400,
		border_TRANSPARENCY:20,
		zoom_BUTTONS_SHOW:'NO',
		pan_BUTTONS_SHOW:'NO',
		pan_LIMIT_BOUNDARY:'NO'
	})
});

function writeObject(){		
	var zoomDataObject = $('#yourImageID').z('getZoomData');		
	$('#code').html(		
		"Normal X: <span style='color:#000000'>"+parseInt(zoomDataObject.normX) +"</span>"
		+"<br />Normal Y: <span style='color:#000000'>"+parseInt(zoomDataObject.normY) +"</span>"
		+"<br />Normal Width: <span style='color:#000000'>"+parseInt(zoomDataObject.normWidth) +"</span>"
		+"<br />Normal Height: <span style='color:#000000'>"+parseInt(zoomDataObject.normHeight) +"</span>"
		+"<br /><br />Scaled X: <span style='color:#000000'>"+parseInt(zoomDataObject.scaledX)  +"</span>"
		+"<br />Scaled Y: <span style='color:#000000'>"+parseInt(zoomDataObject.scaledY) +"</span>"
		+"<br />Scaled Width: <span style='color:#000000'>"+parseInt(zoomDataObject.scaledWidth) +"</span>"
		+"<br />Scaled Height: <span style='color:#000000'>"+parseInt(zoomDataObject.scaledHeight) +"</span>"
		+"<br /><br />Center X: <span style='color:#000000'>"+parseInt(zoomDataObject.centerX) +"</span>"
		+"<br />Center Y: <span style='color:#000000'>"+parseInt(zoomDataObject.centerY) +"</span>"	
		+"<br /><br />Scale Ratio:<br /> <span style='color:#000000'>"+zoomDataObject.ratio +"</span>"	
	);
}

